# @Time    : 2020/2/18 14:28
# @Author  : wumao
# @Email   : kanhebei@dingtalk.com

from . import home_bp
from .helper.func import view
from ...models import Article


@home_bp.route('/')
def welcome():
    article = Article.query.filter_by(status=1)
    newest = article.order_by(Article.id.desc())
    top = newest.filter_by(top=1)
    good = newest.filter_by(good=1)
    hot = newest.order_by(Article.hot.desc())
    return view(
        'index.html',
        top=top,
        good=good,
        hot=hot,
        newest=newest
    )


@home_bp.route('/search')
def search():
    return 'search'
